home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gchess40.lha / gnuchess4.0p62 / src / nondsp.c < prev    next >
C/C++ Source or Header  |  1993-06-22  |  17KB  |  764 lines

  1. /*
  2.  * nondsp.c - UNIX & MSDOS NON-DISPLAY, AND CHESSTOOL interface for Chess
  3.  *
  4.  * Copyright (c) 1988,1989,1990 John Stanback
  5.  * Copyright (c) 1992 Free Software Foundation
  6.  *
  7.  * This file is part of GNU CHESS.
  8.  *
  9.  * GNU Chess is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2, or (at your option)
  12.  * any later version.
  13.  *
  14.  * GNU Chess is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with GNU Chess; see the file COPYING.  If not, write to
  21.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23. extern int EADD,EGET;
  24. extern int TCcount;
  25. #include <ctype.h>
  26. #include <signal.h>
  27. #ifdef MSDOS
  28. #include <dos.h>
  29. /*#include <conio.h>*/
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <time.h>
  33. #else
  34. #include <sys/param.h>
  35. #include <sys/types.h>
  36. #include <sys/file.h>
  37. #include <sys/ioctl.h>
  38. void TerminateSearch (int), Die (int);
  39.  
  40. #endif /* MSDOS */
  41.  
  42. #include "gnuchess.h"
  43.  
  44. #ifdef DEBUG
  45. short int debuglevel = 0;
  46.  
  47. #endif /* DEBUG */
  48. unsigned short int MV[MAXDEPTH];
  49. int MSCORE;
  50.  
  51. #if defined CHESSTOOL || defined XBOARD
  52. short int chesstool = 1;
  53.  
  54. #else
  55. short int chesstool = 0;
  56.  
  57. #endif /* CHESSTOOL */
  58. extern char mvstr[4][6];
  59. int mycnt1, mycnt2;
  60. char *DRAW;
  61. extern char *InPtr;
  62. extern short int pscore[];
  63.  
  64. void
  65. Initialize (void)
  66. {
  67.   mycnt1 = mycnt2 = 0;
  68. #if defined CHESSTOOL || defined XBOARD
  69. #ifndef SYSV
  70.   setlinebuf (stdout);
  71. #else
  72.   setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
  73. #endif
  74.   printf (CP[43]);        /*Chess*/
  75.   if (!TCflag && (MaxResponseTime == 0))
  76.     MaxResponseTime = 15L*100L;
  77. #endif /* CHESSTOOL */
  78. }
  79.  
  80. void
  81. ExitChess (void)
  82. {
  83.   signal (SIGTERM, SIG_IGN);
  84.   ListGame ();
  85.   exit (0);
  86. }
  87.  
  88. #ifndef MSDOS            /* never called!!! */
  89. void
  90. Die (int sig)
  91. {
  92.   char s[80];
  93.  
  94.   ShowMessage (CP[31]);        /*Abort?*/
  95.   scanz ("%s", s);
  96.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  97.     ExitChess ();
  98. }
  99.  
  100. #endif /* MSDOS */
  101.  
  102. void
  103. TerminateSearch (int sig)
  104. {
  105. #ifdef MSDOS
  106.   sig++;            /* shut up the compiler */
  107. #endif /* MSDOS */
  108.   if (!flag.timeout)
  109.     flag.back = true;
  110.   flag.bothsides = false;
  111. }
  112.  
  113.  
  114. void
  115. help (void)
  116. {
  117.   ClrScreen ();
  118.   /*printz ("CHESS command summary\n");*/
  119.   printz (CP[40]);
  120.   printz ("----------------------------------------------------------------\n");
  121.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  122.   printz (CP[158]);
  123.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  124.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  125.   /*printz ("a7a8q     promote pawn to queen\n");*/
  126.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  127.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  128.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  129.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  130.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  131.   /*printz ("bd        redraw board            reverse   board display\n");*/
  132.   printz (CP[130]);
  133.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount);*/
  134.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount,booksize);
  135.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  136.   printz (CP[200]);
  137.   /*printz ("edit      edit board              force     enter game moves\n");*/
  138.   printz (CP[153]);
  139.   /*printz ("switch    sides with computer     both      computer match\n");*/
  140.   printz (CP[194]);
  141.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  142.   printz (CP[202]);
  143.   /*printz ("depth     set search depth        clock     set time control\n");*/
  144.   printz (CP[149]);
  145.   /*printz ("post      principle variation     hint      suggest a move\n");*/
  146.   printz (CP[177]);
  147.   /*printz ("save      game to file            get       game from file\n");*/
  148.   printz (CP[188]);
  149.   /*printz ("random    randomize play          new       start new game\n");*/
  150.   printz (CP[181]);
  151.   printz ("----------------------------------------------------------------\n");
  152.   /*printz ("Computer: %-12s Opponent:            %s\n",*/
  153.   printz (CP[46],
  154.       ColorStr[computer], ColorStr[opponent]);
  155.   /*printz ("Depth:    %-12d Response time:       %d sec\n",*/
  156.   printz (CP[51],
  157.       MaxSearchDepth, MaxResponseTime/100);
  158.   /*printz ("Random:   %-12s Easy mode:           %s\n",*/
  159.   printz (CP[99],
  160.       (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
  161.   /*printz ("Beep:     %-12s Transposition file: %s\n",*/
  162.   printz (CP[36],
  163.       (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
  164.   /*printz ("Time Control %s %d moves %d seconds %d opr %d depth\n", (TCflag) ? "ON" : "OFF",*/
  165.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  166.       TimeControl.moves[white], TimeControl.clock[white] / 100, TCadd/100, MaxSearchDepth);
  167.   signal (SIGINT, TerminateSearch);
  168. #ifndef MSDOS
  169.   signal (SIGQUIT, TerminateSearch);
  170. #endif /* MSDOS */
  171. }
  172.  
  173. void
  174. EditBoard (void)
  175.  
  176. /*
  177.  * Set up a board position. Pieces are entered by typing the piece followed
  178.  * by the location. For example, Nf3 will place a knight on square f3.
  179.  */
  180.  
  181. {
  182.   short a, r, c, sq, i, found;
  183.   char s[80];
  184.  
  185.   flag.regularstart = true;
  186.   Book = BOOKFAIL;
  187.   ClrScreen ();
  188.   UpdateDisplay (0, 0, 1, 0);
  189.   /*printz (".   exit to main\n");*/
  190.   printz (CP[29]);
  191.   /*printz ("#   clear board\n");*/
  192.   printz (CP[28]);
  193.   /*printz ("c   change sides\n");*/
  194.   printz (CP[136]);
  195.   /*printz ("enter piece & location: \n");*/
  196.   printz (CP[155]);
  197.  
  198.   a = white;
  199.   do
  200.     {
  201.       scanz ("%s", s);
  202.       found=0;
  203.       if (s[0] == CP[28][0])    /*#*/
  204.     for (sq = 0; sq < 64; sq++)
  205.       {
  206.         board[sq] = no_piece;
  207.         color[sq] = neutral;
  208.       }
  209.       else if (s[0] == CP[136][0])    /*c*/
  210.     a = otherside[a];
  211.       else {
  212.       c = s[1] - 'a';
  213.       r = s[2] - '1';
  214.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  215.     {
  216.       sq = locn (r, c);
  217.       color[sq] = a;
  218.       board[sq] = no_piece;
  219.       for (i = no_piece; i <= king; i++)
  220.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  221.           {
  222.         board[sq] = i;
  223.         found=1;
  224.         break;
  225.           }
  226.       if (found==0) color[sq] = neutral;    
  227.     }
  228.     }
  229.   } while (s[0] != CP[29][0]);
  230.   for (sq = 0; sq < 64; sq++)
  231.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  232.   GameCnt = 0;
  233.   Game50 = 1;
  234.   ZeroRPT ();
  235.   Sdepth = 0;
  236.   InitializeStats ();
  237.   ClrScreen ();
  238.   UpdateDisplay (0, 0, 1, 0);
  239. }
  240.  
  241. void
  242. SetupBoard (void)
  243.  
  244. /*
  245.  * Compatibility with Unix chess and the nchesstool. Set up a board position.
  246.  * Eight lines of eight characters are used to setup the board. a8-h8 is the
  247.  * first line. Black pieces are  represented  by  uppercase characters.
  248.  */
  249.  
  250. {
  251.   short r, c, sq, i;
  252.   char ch;
  253.   char s[80];
  254.  
  255.   NewGame ();
  256.  
  257.   gets (s);            /* skip "setup" command */
  258.   for (r = 7; r >= 0; r--)
  259.     {
  260.       gets (s);
  261.       for (c = 0; c <= 7; c++)
  262.     {
  263.       ch = s[c];
  264.       sq = locn (r, c);
  265.       color[sq] = neutral;
  266.       board[sq] = no_piece;
  267.       for (i = no_piece; i <= king; i++)
  268.         if (ch == pxx[i])
  269.           {
  270.         color[sq] = black;
  271.         board[sq] = i;
  272.         break;
  273.           }
  274.         else if (ch == qxx[i])
  275.           {
  276.         color[sq] = white;
  277.         board[sq] = i;
  278.         break;
  279.           }
  280.     }
  281.     }
  282.   for (sq = 0; sq < 64; sq++)
  283.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  284.   InitializeStats ();
  285.   ClrScreen ();
  286.   UpdateDisplay (0, 0, 1, 0);
  287.   /*printz ("Setup successful\n");*/
  288.   printz (CP[106]);
  289. }
  290.  
  291. void
  292. ShowDepth (char ch)
  293. {
  294. #ifdef MSDOS
  295.   ch++;                /* shut up the compiler */
  296. #endif /* MSDOS */
  297. }
  298.  
  299.  
  300. void
  301. ShowLine (short unsigned int *bstline)
  302. {
  303.   register int i;
  304.  
  305.   for (i = 1; bstline[i] > 0; i++)
  306.     {
  307.       if ((i > 1) && (i % 8 == 1))
  308.     printf ("\n                          ");
  309.       algbr ((short) (bstline[i] >> 8), (short) (bstline[i] & 0xFF), false);
  310.       printf ("%5s ", mvstr[0]);
  311.     }
  312.   printf ("\n");
  313. }
  314.  
  315. void
  316. ShowResults (short int score, short unsigned int *bstline, char ch)
  317. {
  318. #if !defined CHESSTOOL
  319.   if (flag.post)
  320.     {
  321.       ElapsedTime (2);
  322.       printf ("%2d%c %6d %4ld %8ld  ", Sdepth, ch, score, et / 100, NodeCnt);
  323.       ShowLine (bstline);
  324.     }
  325. #else
  326.   register int i;
  327.  
  328.   MSCORE = score;
  329.   MV[30] = ch;
  330.   for (i = 1; bstline[i] > 0; i++)
  331.     {
  332.       MV[i] = bstline[i];
  333.     } MV[i] = 0;
  334. #endif /* CHESSTOOL */
  335. }
  336.  
  337. void
  338. SearchStartStuff (short int side)
  339. {
  340.   signal (SIGINT, TerminateSearch);
  341. #ifndef MSDOS
  342.   signal (SIGQUIT, TerminateSearch);
  343. #endif /* MSDOS */
  344. #if !defined CHESSTOOL
  345.   if (flag.post)
  346.     {
  347.       printf (CP[123],
  348.            GameCnt/2+1,
  349.            ResponseTime, TimeControl.clock[side]);
  350.     }
  351. #endif /* CHESSTOOL */
  352. }
  353. void
  354. #ifdef XBOARD
  355. OutputMove (int score, short unsigned int *bstline)
  356. #else
  357. OutputMove (void)
  358. #endif
  359. {
  360. #ifdef DEBUG11
  361.   if (1)
  362.     {
  363.       FILE *D;
  364.       extern unsigned short int PrVar[];
  365.       char d[80];
  366.       int r, c, l, i;
  367.       D = fopen ("/tmp/DEBUGA", "a+");
  368.       fprintf (D, "inout move is %s\n", mvstr[0]);
  369.       strcpy (d, mvstr[0]);
  370.       for (i = 1; PrVar[i] > 0; i++)
  371.     {
  372.       algbr ((short) (PrVar[i] >> 8), (short) (PrVar[i] & 0xFF), false);
  373.       fprintf (D, "%5s ", mvstr[0]);
  374.     }
  375.       fprintf (D, "\n");
  376.  
  377.       fprintf (D, "\n current board is\n");
  378.       for (r = 7; r >= 0; r--)
  379.     {
  380.       for (c = 0; c <= 7; c++)
  381.         {
  382.           l = locn (r, c);
  383.           if (color[l] == neutral)
  384.         fprintf (D, " -");
  385.           else if (color[l] == white)
  386.         fprintf (D, " %c", qxx[board[l]]);
  387.           else
  388.         fprintf (D, " %c", pxx[board[l]]);
  389.         }
  390.       fprintf (D, "\n");
  391.     }
  392.       fprintf (D, "\n");
  393.       fclose (D);
  394.       strcpy (mvstr[0], d);
  395.     }
  396. #endif
  397. if(flag.illegal){printf("%s\n",CP[225]);return;}
  398. if (mvstr[0][0] == '\0') goto nomove;
  399. #if defined CHESSTOOL
  400.   if (computer == black)
  401.     printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  402.   else
  403.     printz ("%d. %s\n", ++mycnt1, mvstr[0]);
  404. #else
  405. #ifdef XBOARD
  406.   printz ("%d. ... %s %d ", ++mycnt1, mvstr[0], score);
  407.   ShowLine(bstline);
  408. #else
  409.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  410. #endif
  411. #endif /* CHESSTOOL */
  412. #ifdef notdef /* optional pass best line to frontend with move */
  413.   if (flag.post)
  414.     {
  415.       register int i;
  416.  
  417.       printz (" %6d%c ", MSCORE, MV[30]);
  418.       for (i = 1; MV[i] > 0; i++)
  419.     {
  420.       algbr ((short) (MV[i] >> 8), (short) (MV[i] & 0xFF), false);
  421.       printz ("%5s ", mvstr[0]);
  422.     }
  423.     }
  424.   printz ("\n");
  425. #endif
  426. nomove:
  427.   if ((root->flags & draw)||(root->score == -9999)||
  428.       (root->score == 9998)) goto summary;
  429. #ifndef BAREBONES
  430.   if (flag.post)
  431.     {
  432.       short h, l, t;
  433.  
  434.       h = TREE;
  435.       l = 0;
  436.       t = TREE >> 1;
  437.       while (l != t)
  438.     {
  439.       if (Tree[t].f || Tree[t].t)
  440.         l = t;
  441.       else
  442.         h = t;
  443.       t = (l + h) >> 1;
  444.     }
  445.       /*printf ("Nodes %ld Tree %d Eval %ld Rate %ld RS high %ld low %ld\n",*/
  446.       printf (CP[89],GenCnt,NodeCnt,t,EvalNodes,(et>100)?(NodeCnt/(et/100)):0,EADD,EGET,reminus,replus);
  447.       /*printf ("Hin/Hout/Coll/Fin/Fout = %ld/%ld/%ld/%ld/%ld\n",*/
  448.       printf (CP[71],
  449.            HashAdd, HashCnt, THashCol, HashCol,FHashCnt, FHashAdd);
  450.     }
  451.   UpdateDisplay (root->f, root->t, 0, root->flags);
  452.   /*printf ("My move is: %s\n", mvstr[0]);*/
  453.   printf (CP[83], mvstr[0]);
  454.   if (flag.beep)
  455.     printz ("%c", 7);
  456. #endif /* CHESSTOOL */
  457.  summary:
  458.   if (root->flags & draw)
  459.     /*    printf ("Drawn game!\n");*/
  460.     printf (CP[57]);
  461.   else if (root->score == -9999)
  462.     printf("%s mates!\n",ColorStr[opponent]);
  463.   else if (root->score == 9998)
  464.     printf("%s mates!\n",ColorStr[computer]);
  465. #if !defined CHESSTOOL && !defined XBOARD
  466. #ifdef VERYBUGGY
  467.   else if (root->score < -9000)
  468.     printf("%s has a forced mate!\n",ColorStr[opponent]);
  469.   else if (root->score > 9000)
  470.     printf("%s has a forced mate!\n",ColorStr[computer]);
  471. #endif /*VERYBUGGY*/
  472. #endif /* CHESSTOOL */
  473. }
  474.  
  475. void
  476. ClrScreen (void)
  477. {
  478. #if !defined CHESSTOOL && !defined XBOARD
  479.   printz ("\n");
  480. #endif
  481. }
  482.  
  483. void
  484. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  485. {
  486.  
  487.   short r, c, l, m;
  488.  
  489.   if (redraw && !chesstool)
  490.     {
  491.       printz ("\n");
  492.       r = (short)(TimeControl.clock[white] / 6000);
  493.       c = (short)((TimeControl.clock[white] % 6000) / 100);
  494.       l = (short)(TimeControl.clock[black] / 6000);
  495.       m = (short)((TimeControl.clock[black] % 6000) / 100);
  496.       /*printz ("White %d:%02d  Black %d:%02d\n", r, c, l, m);*/
  497.       printz (CP[116], r, c, l, m);
  498.       printz ("\n");
  499.       for (r = 7; r >= 0; r--)
  500.     {
  501.       for (c = 0; c <= 7; c++)
  502.         {
  503.           l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  504.           if (color[l] == neutral)
  505.         printz (" -");
  506.           else if (color[l] == white)
  507.         printz (" %c", qxx[board[l]]);
  508.           else
  509.         printz (" %c", pxx[board[l]]);
  510.         }
  511.       printz ("\n");
  512.     }
  513.       printz ("\n");
  514.     }
  515. }
  516.  
  517. void
  518. skip ()
  519. {
  520.   while (*InPtr != ' ')
  521.     InPtr++;
  522.   while (*InPtr == ' ')
  523.     InPtr++;
  524. }
  525. void
  526. skipb ()
  527. {
  528.   while (*InPtr == ' ')
  529.     InPtr++;
  530. }
  531.  
  532. void
  533. ShowMessage (char *s)
  534. {
  535.   printf("%s\n", s);
  536. }
  537.  
  538. void
  539. ShowSidetoMove (void)
  540. {
  541. }
  542.  
  543. void
  544. PromptForMove (void)
  545. {
  546. #if !defined CHESSTOOL && !defined XBOARD
  547.   /*printz ("\nYour move is? ");*/
  548.   printz (CP[124]);
  549. #endif /* CHESSTOOL */
  550. }
  551.  
  552.  
  553. void
  554. ShowCurrentMove (short int pnt, short int f, short int t)
  555. {
  556. #ifdef MSDOS
  557.   f++;
  558.   t++;
  559.   pnt++;            /* shut up the compiler */
  560. #endif /* MSDOS */
  561. }
  562.  
  563. void
  564. ChangeAlphaWindow (void)
  565. {
  566.   printz ("WAwindow: ");
  567.   scanz ("%hd", &WAwindow);
  568.   printz ("BAwindow: ");
  569.   scanz ("%hd", &BAwindow);
  570. }
  571.  
  572. void
  573. ChangeBetaWindow (void)
  574. {
  575.   printz ("WBwindow: ");
  576.   scanz ("%hd", &WBwindow);
  577.   printz ("BBwindow: ");
  578.   scanz ("%hd", &BBwindow);
  579. }
  580.  
  581. void
  582. GiveHint (void)
  583. {
  584.   if (hint)
  585.     {
  586.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  587.       printf(CP[72], mvstr[0]);    /*hint*/
  588.     }
  589.   else
  590.     printz (CP[223]);
  591. }
  592.  
  593. void
  594. SelectLevel (char *sx)
  595. {
  596.  
  597.   char T[64], *p, *q;
  598.  
  599.   if((p = strstr(sx,CP[169]))!=NULL) p += strlen(CP[169]);
  600.   else if((p = strstr(sx,CP[217]))!=NULL) p += strlen(CP[217]);
  601.   strcat(sx,"XX");
  602.   q = T; *q = '\0';
  603.   for(;*p != 'X';*q++ = *p++);
  604.   *q = '\0';
  605. /* line empty ask for input */
  606.   if(!T[0]){ printz (CP[61]); gets(T); strcat(T,"XX"); }
  607. /* skip whitespace */
  608.   for (p = T; *p == ' '; p++) ;
  609. /* could be moves or a fischer clock */
  610.   if(*p == 'f') { /* its a fischer clock game */
  611.     p++;
  612.     TCminutes = (short)strtol(p,&q,10);
  613.     TCadd = (short)strtol(q,NULL,10) *100;
  614.     TCseconds = 0;
  615.     TCmoves = 50;
  616.   } else { /* regular game */
  617.   TCadd = 0;
  618.   TCmoves = (short)strtol (p, &q, 10);
  619.   TCminutes = (short)strtol (q, &q, 10);
  620.   if (*q == ':')
  621.     TCseconds = (short)strtol (q + 1, (char **) NULL, 10);
  622.   else
  623.     TCseconds = 0;
  624. #ifdef OPERATORTIME
  625.   printz (CP[94]);
  626.   scanz ("%hd", &OperatorTime);
  627. #endif
  628.   if (TCmoves == 0) {
  629.     TCflag = false;
  630.     MaxResponseTime = TCminutes*60L*100L + TCseconds*100L;
  631.     TCminutes = TCseconds = 0;
  632.   } else {
  633.     TCflag = true;
  634.     MaxResponseTime = 0;
  635.   }
  636. }
  637.   TimeControl.clock[white] = TimeControl.clock[black] = 0;
  638.   SetTimeControl ();
  639. }
  640.  
  641. #ifdef DEBUG
  642. void
  643. ChangeDbLev (void)
  644. {
  645.   printz (CP[146]);
  646.   scanz ("%hd", &debuglevel);
  647. }
  648.  
  649. #endif /* DEBUG */
  650.  
  651. void
  652. ChangeSearchDepth (void)
  653. {
  654.   printz ("depth= ");
  655.   scanz ("%hd", &MaxSearchDepth);
  656.   TCflag = !(MaxSearchDepth > 0);
  657. }
  658.  
  659. void
  660. ChangeHashDepth (void)
  661. {
  662.   printz ("hashdepth= ");
  663.   scanz ("%hd", &HashDepth);
  664.   printz ("MoveLimit= ");
  665.   scanz ("%hd", &HashMoveLimit);
  666. }
  667.  
  668. void
  669. SetContempt (void)
  670. {
  671.   printz ("contempt= ");
  672.   scanz ("%hd", &contempt);
  673. }
  674.  
  675. void
  676. ChangeXwindow (void)
  677. {
  678.   printz ("xwndw= ");
  679.   scanz ("%hd", &xwndw);
  680. }
  681.  
  682. void
  683. ShowPostnValue (short int sq)
  684.  
  685. /*
  686.  * must have called ExaminePosition() first
  687.  */
  688.  
  689. {
  690.   short score;
  691.   score = ScorePosition (color[sq]);
  692.   if (color[sq] != neutral){
  693.     printz ("%3d%c ", svalue[sq],(color[sq] == black)?'b':'w');}
  694.   else
  695.     printz(" *   ");
  696. }
  697.  
  698. void
  699. DoDebug (void)
  700. {
  701.   short c, p, sq, tp, tc, tsq, score,j,k;
  702.   char s[40];
  703.  
  704.   ExaminePosition ();
  705.   ShowMessage (CP[65]);
  706.   scanz ("%s", s);
  707.   c = neutral;
  708.   if (s[0] == CP[9][0] || s[0] == CP[9][1])     /* w W*/ c = white;
  709.   if (s[0] == CP[9][2] || s[0] == CP[9][3])     /*b B*/ c = black;
  710.   for (p = king; p > no_piece; p--)
  711.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  712.   if(p > no_piece)
  713.   for(j=7;j>=0;j--){
  714.   for(k=0;k<8;k++){
  715.       sq=j*8+k;
  716.       tp = board[sq];
  717.       tc = color[sq];
  718.       board[sq] = p;
  719.       color[sq] = c;
  720.       tsq = PieceList[c][1];
  721.       PieceList[c][1] = sq;
  722.       ShowPostnValue (sq);
  723.       PieceList[c][1] = tsq;
  724.       board[sq] = tp;
  725.       color[sq] = tc;
  726.     }
  727.       printz("\n");
  728.     }
  729.   score = ScorePosition (opponent);
  730.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  731. }
  732.  
  733. void
  734. DoTable (short table[64])
  735. {
  736.   short  sq,j,k;
  737.   ExaminePosition ();
  738.   for(j=7;j>=0;j--){
  739.   for(k=0;k<8;k++){
  740.     sq=j*8+k;
  741.     printz ("%3d ", table[sq]);
  742.   }
  743. printz("\n");
  744. }
  745. }
  746.  
  747. void
  748. ShowPostnValues (void)
  749. {
  750.   short sq, score,j,k;
  751.   ExaminePosition ();
  752.   for(j=7;j>=0;j--){
  753.   for(k=0;k<8;k++){
  754.   sq=j*8+k;
  755.     ShowPostnValue (sq);
  756.   }
  757.     printz("\n");
  758.   }
  759.   score = ScorePosition (opponent);
  760.  printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  761.  printz("\nhung white %d hung black %d\n",hung[white],hung[black]);
  762. }
  763.  
  764.